home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / doc.zoo / doc / usrman / doc.6 < prev    next >
Encoding:
Text File  |  1989-01-24  |  11.5 KB  |  446 lines

  1. '\"                        Copyright (c) 1988 Bellcore
  2. '\"                            All Rights Reserved
  3. '\"       Permission is granted to copy or use this program, EXCEPT that it
  4. '\"       may not be sold for profit, the copyright notice must be reproduced
  5. '\"       on copies, and credit should be given to Bellcore where it is due.
  6. '\"       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7. '\"
  8. '\"    $Header: doc.6,v 4.1 88/06/29 17:05:09 bianchi Exp $
  9. '\"    $Source: /tmp/mgrsrc/doc/usrman/RCS/doc.6,v $
  10. .Sh page Using the Library
  11. Clients using 
  12. .I
  13. The C Interface Library
  14. .R
  15. should specify:
  16. .DS
  17. .ft \*(Ff
  18. #include "term.h"
  19. .ft R
  20. .DE
  21. which also includes 
  22. .DS
  23. .ft \*(Ff
  24. <stdio.h>
  25. .ft R
  26. .DE
  27. if it has not already been included.
  28. Programs are compiled either with
  29. .DS
  30. .ft \*(Ff
  31. cc -o foo foo.c term.o -I$(lib)
  32. .ft R
  33. .DE
  34. where $(lib) is the \*M include directory
  35. or simply
  36. .DS
  37. .ft \*(Ff
  38. cc -o foo foo.c -lmgr
  39. .ft R
  40. .DE
  41. if the library is installed in a standard location.
  42. The file
  43. .I term.o
  44. contains the functions listed in the last section.
  45. Several compile time options are available to the client program using
  46. the library.
  47. Normally, the library setup routine,
  48. .Fr m_setup
  49.  attempts to open 
  50. .I /dev/tty
  51. to communicate with \*M.
  52. Client programs may define the C preprocessor symbols
  53. .SM
  54. .I M_DEVICEIN
  55. .LG
  56. or
  57. .SM
  58. .I M_DEVICEOUT
  59. .LG
  60. to override the selection of
  61. .I /dev/tty
  62. for input or output respectively.
  63. After each macro call,
  64. the flush flag
  65. .SM
  66. .I M_FLUSH
  67. .LG
  68. is tested to see if output should be flushed to \*M.
  69. If the C preprocessor symbol
  70. .SM
  71. .I M_NOFLUSH
  72. .LG
  73. is defined, before the client program includes
  74. .I term.h ,
  75. The flush flag is never tested, and it becomes the responsibility of the
  76. client program to insure output is flushed at the appropriate times.
  77. .LP
  78. Several external variables maintained by the library are accessible to
  79. client programs.
  80. The
  81. .I stdio
  82. .SM
  83. .I FILE
  84. .LG
  85. pointers
  86. .I m_termin
  87. and
  88. .I m_termout
  89. are used for directing output to, and receiving input from \*M.
  90. These file pointers are initialized in
  91. .Fr m_setup
  92. \&, and may be changed by client programs after
  93. .Fr m_setup
  94.  is called.
  95. The integer
  96. .I m_flags
  97. contains the current library mode settings, as returned by
  98. .Fr m_setup
  99. \&.
  100. The 
  101. .SM
  102. .I M_MODEOK
  103. .LG
  104. and
  105. .SM
  106. .I M_FLUSH
  107. .LG
  108. bits of 
  109. .I m_flags
  110. may also be changed at any time after 
  111. .Fr m_setup 
  112.  is called.
  113. The integer
  114. .I m_envcount
  115. contains the current window context depth, and is used by
  116. .Fr m_popall
  117. to pop the appropriate number of contexts.
  118. .I M_envcount
  119. should not be changed by client programs.
  120. Finally, the character
  121. .I m_menuchar
  122. defines the menu separator character used by
  123. .Fr menu_load
  124. \&.
  125. This character, set to '\e005' by the library package,
  126. can be changed to any character that will not appear as part of
  127. a menu item or action.
  128. .Sh page Glossary
  129. .IP "\fBabsolute coordinates\fP" 0.5i
  130. .br
  131. .I "Absolute coordinates"
  132. is a coordinate system used in
  133. .I windows
  134. measured in units of pixels.
  135. .IP "\fBactive window\fP" 0.5i
  136. .br
  137. The
  138. .I active
  139. window is the window logically in the front of the display, which is
  140. receiving keyboard and mouse input.
  141. .IP "\fBalternate window\fP" 0.5i
  142. .br
  143. An
  144. .I "alternate window"
  145. is an additional window created by a client program that shares the
  146. communication channel with the main window.
  147. .IP \fBbitmap\fP 0.5i
  148. .br
  149. A
  150. .I bitmap
  151. is a rectangular array of bits, or pixels if the bitmap is
  152. currently on the display.
  153. .IP \fBchannel\fP 0.5i
  154. .br
  155. The
  156. .I channel
  157. is the bidirectional byte stream connecting \*M with
  158. the client program.
  159. The 
  160. .I channel
  161. is usually the program's standard input and output.
  162. .IP "\fBcharacter coordinates\fP" 0.5i
  163. .br
  164. .I "Character coordinates"
  165. is the 
  166. coordinate system used in windows for counting characters in
  167. .I columns
  168. and
  169. .I rows .
  170. .IP "\fBcharacter cursor\fP" 0.5i
  171. .br
  172. The
  173. .I "character cursor"
  174. is the location in the window where the next character will be placed.
  175. The cursor location is always highlighted on the active window.
  176. .IP "\fBchild menu\fP" 0.5i
  177. .br
  178. A
  179. .I "child menu"
  180. is the
  181. menu that will pop up when the user slides off to the right
  182. of a popped up 
  183. .I "parent menu" .
  184. .IP "\fBclient program\fP" 0.5i
  185. .br
  186. A
  187. .I "client program"
  188. is any Unix command that is running in an \*M window.
  189. Client programs may be existing programs, as might be found in
  190. .I /bin
  191. or new applications written specifically to take advantage of the
  192. windowing environment.
  193. .IP \fBclient-host\fP 0.5i
  194. .br
  195. The
  196. .I "client-host"
  197. is the computer that the client program is running on.
  198. It is often the same as the
  199. .I \*M-host
  200. machine, but it does not need to be.
  201. .IP "\fBdisplay coordinates\fP" 0.5i
  202. .I "Display coordinates"
  203. is a coordinate system used to measure pixels on the display.
  204. The top left corner of the display is at (0,0), with
  205. .I x
  206. increasing to the right, and
  207. .I y
  208. increasing down.
  209. .br
  210. .IP \fBexposed\fP 0.5i
  211. .br
  212. A window is
  213. .I exposed
  214. if it is entirely visible.
  215. .IP "\fBgraphics point\fP" 0.5i
  216. .br
  217. The
  218. .I "graphics point"
  219. is a location on the window, measured in the prevailing window
  220. coordinate system, that may serve as a reference location 
  221. or origin for many of the graphics operations.
  222. .IP \fBlistener\fP 0.5i
  223. .br
  224. .I listener
  225. is a window that has turned on the
  226. .SM
  227. .Fi ACCEPT
  228. .LG
  229. event and is willing to receive messages from other client programs.
  230. .IP "\fBmain window\fP" 0.5i
  231. .br
  232. A client program's
  233. .I "main window"
  234. is the window the program was started in.
  235. The client program may create and destroy alternate windows,
  236. but not its
  237. .I "main window" .
  238. If the user destroys a client program's
  239. .I " main window" ,
  240. the connection
  241. to \*M is severed, and the client program receives a
  242. .I hangup
  243. signal.
  244. .IP \fB\*M-host\fP 0.5i
  245. .br
  246. The
  247. \*M-host is the computer that \*M is running on. 
  248. .IP "\fBmouse cursor\fP" 0.5i
  249. .br
  250. The
  251. .I "mouse cursor"
  252. is a small bitmap or
  253. .I icon
  254. that tracks the movement of the mouse on the display.
  255. Normally the
  256. .I "mouse cursor"
  257. is a small arrow pointing north west.
  258. .IP \fBobscured\fP 0.5i
  259. .br
  260. A window is
  261. .I obscured
  262. when it is partially or totally covered by another
  263. window.
  264. .IP "\fBparent menu\fP" 0.5i
  265. .br
  266. A  menu is called a
  267. .I "parent menu"
  268. when sliding off to the right of a selected item causes
  269. another menu or
  270. .I "child menu"
  271. to pop up.
  272. .IP "\fBrelative coordinates\fP" 0.5i
  273. .br
  274. .I "Relative coordinates"
  275. is a coordinate system for windows where a single unit represents one
  276. thousandth of the way across (or down) the window.
  277. .IP "\fBscratchpad bitmap\fP" 0.5i
  278. .br
  279. .I "scratchpad bitmap"
  280. is a chunk of memory, allocated by \*M for use by a client program,
  281. that may hold a bitmap image that is not on the display.
  282. .IP "\fBsnarf buffer\fP" 0.5i
  283. .br
  284. The
  285. .I "snarf buffer"
  286. is a buffer maintained by \*M of arbitrary size that is accessible by all
  287. client programs.
  288. .IP "\fBtarget window\fP" 0.5i
  289. .br
  290. A
  291. .I "target window"
  292. is a window that is to receive a message from another window.
  293. .IP "\fBtext region\fP" 0.5i
  294. .br
  295. .I "text region"
  296. is the part of the window in which character text and the 
  297. functions that operate on characters work.
  298. The
  299. .I "text region"
  300. may be the entire window (the default)
  301. or a rectangular subregion within the window.
  302. .IP "\fBwindow border\fP" 0.5i
  303. .br
  304. The
  305. .I "window border"
  306. is a thin black border around every window that separates the
  307. window from the rest of the display.
  308. .IP "\fBwindow context\fP" 0.5i
  309. .br
  310. A
  311. .I "window context"
  312. contains the values for one or more aspects of the window's
  313. state.
  314. .I "Window context"
  315. a may be saved on a stack, and then restored at some later time.
  316. .IP "\fBwindow id\fP" 0.5i
  317. .br
  318. A
  319. .I "window id"
  320. is a unique number assigned to every window that may be used
  321. as an identifier when sending a message to the window.
  322. .I "Window id" s
  323. have two parts,
  324. the first part is the process number of the client program that
  325. was started when the window was created,
  326. the second part is the windows
  327. .I alternate
  328. window number, or
  329. zero for a main window.
  330. .Sh page Sample Client Program
  331. .LP
  332. This program, called
  333. .I close ,
  334. closes, or iconifies a window.  
  335. Its not a terribly useful application in its own right, but it does
  336. exercise several of the library calls.
  337. When 
  338. .I close
  339. starts up, it makes the window smaller,
  340. moves it toward the top of the display,
  341. then writes the word "closed" in it.
  342. If the window is covered by another window,
  343. it changes the word "closed" to "hidden", then flashes its window every
  344. 15 seconds as long as the window is covered.
  345. If the window is then uncovered, the word "hidden" gets changed back
  346. to "closed".
  347. Activating the window causes
  348. .I close
  349. to restore the window's original shape and contents, then exit.
  350. .LP
  351. .SS
  352. /* iconify a MGR window */
  353.  
  354. #include <signal.h>
  355. #include "term.h"
  356.  
  357. #define TIME    15                /* time interval for reminder */
  358. #define CONTEXT P_POSITION | P_WINDOW | P_FLAGS | P_EVENT | P_CURSOR
  359.  
  360. static char line[80];             /* event input buffer */
  361.  
  362. main()
  363.     {
  364.     int clean(), timer();         /* interrupt routines */
  365.     int x,y;                      /* window position on display */
  366.     char *msg = "closed";         /* closed window "icon" */
  367.  
  368.     /* setup the window environment */
  369.  
  370.     m_setup(M_FLUSH);             /* setup i/o, turn on flushing */
  371.     m_push(CONTEXT);              /* save current window context */
  372.     m_setmode(M_NOWRAP);          /* don't auto-wrap at right margin */
  373.     m_ttyset();                   /* set up tty modes */
  374.  
  375.     /* catch the appropriate signals */
  376.  
  377.     signal(SIGTERM,clean);        /* in case we get terminated */
  378.     signal(SIGALRM,timer);        /* for the reminder service */
  379.  
  380.     /* iconify the window */
  381.  
  382.     get_size(&x,&y,0,0);          /* fetch window coordinates */
  383.     m_sizeall(x,10,strlen(msg),1);/* move and resize window */
  384.     m_clear();                    /* clear the window */
  385.     m_printstr(msg);              /* print message in the window */
  386.  
  387.     /* catch events */
  388.  
  389.     m_setevent(ACTIVATE, "A\er"); /* window is now the active window */
  390.     m_setevent(COVERED,  "C\er"); /* covered by another window */
  391.     m_setevent(UNCOVERED,"U\er"); /* completely visible */
  392.     m_setevent(REDRAW,   "R\er"); /* redraw requested */
  393.  
  394.     m_clearmode(M_ACTIVATE);      /* bury the window */
  395.  
  396.     /* wait for an event */
  397.  
  398.     while(m_gets(line) != NULL)   /* read a line from MGR */
  399.         switch (*line) {
  400.         case 'A':                 /* window is activated */
  401.             clean();              /* clean up and exit */
  402.             break;
  403.         case 'C':                 /* window is covered */
  404.             m_clear();
  405.             m_printstr("hidden");
  406.             alarm(TIME);          /* turn on reminder */
  407.             break;
  408.         case 'R':                 /* system 'redraw' */
  409.         case 'U':                 /* window is uncovered */
  410.             m_clear();
  411.             m_printstr(msg);
  412.             alarm(0);             /* turn off reminder */
  413.             break;
  414.         case 'T':                 /* send reminder */
  415.             m_setmode(M_WOB);     /* highlight window */
  416.             m_bell();             /* ring the bell */
  417.             sleep(1);
  418.             alarm(TIME);          /* reset reminder timer */
  419.             m_clearmode(M_WOB);   /* reset window highlighting */
  420.             break;
  421.         }
  422.     }
  423.  
  424. clean()                           /* clean up and exit */
  425.     {
  426.     m_ttyreset();                 /* reset tty modes */
  427.     m_popall();                   /* restore window context */
  428.     exit(0);
  429.     }
  430.  
  431. timer()                           /* called at reminder timeout */
  432.     {
  433.     m_sendme("T\er");             /* send timeout message */
  434.     }
  435. .SE
  436. .Sh page Macros and Functions by Category
  437. .LP
  438. .FS *
  439. The routines marked with a dagger (\(dg) are functions,
  440. the other routines are macros.  The page number on which the macro or
  441. function is defined is printed in bold face after the name.
  442. .FE
  443.